//
//  TabletPlanTimesAndDosesCell.m
//  yilutongxing
//
//  Created by T&J on 2018/4/14.
//  Copyright © 2018年 YZE. All rights reserved.
//

#import "TabletPlanTimesAndDosesCell.h"
#import "DataUtils.h"

@interface TabletPlanTimesAndDosesCell()
@property (strong, nonatomic) IBOutlet UIView *timerow;
@property (strong, nonatomic) IBOutlet UILabel *xuhao;
@property (strong, nonatomic) IBOutlet UILabel *timelabel;
@property (strong, nonatomic) IBOutlet UIView *doserow;
@property (strong, nonatomic) IBOutlet UILabel *doselabel;
@property (strong, nonatomic) IBOutlet UITextField *dosetextfield;
@end

@implementation TabletPlanTimesAndDosesCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.timerow.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(timerowTaped)];
    [self.timerow addGestureRecognizer:tap1];
    self.doserow.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doserowTaped)];
    [self.doserow addGestureRecognizer:tap2];
    
    [self.dosetextfield addTarget:self action:@selector(onDosetextChanged:) forControlEvents: UIControlEventEditingChanged];
}

- (void)timerowTaped{
    debugLog(@"点击了序号行！");
    [self.delegate onTimerowTapedFortag:self.tag];
}

- (void)doserowTaped{
    debugLog(@"点击了剂量行！");
    [self.delegate onDoserowTapedFortag:self.tag];
}

- (void)onDosetextChanged:(UITextField*)textField{
    [self.delegate onDosetexted:textField.text forTag:self.tag];
}

- (void)setOrdertitle:(long)index{
    NSString *title = [NSString stringWithFormat:@"第%@次", [DataUtils arabicConvert2Chinese:index]];
    self.xuhao.text = title?title:@" ";
}

- (void)setTaketime:(NSString *)time{
    self.timelabel.text = time?time:@" ";
}

- (void)setDose:(NSString *)dose{
    self.dosetextfield.text = dose?dose:@" ";
}

- (void)setUnit:(NSString*)unit{
    self.doselabel.text = unit?unit:@" ";
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
